//
//  PetQuiltViewCell.m
//  TMQuiltView(瀑布流)
//
//  Created by xindao on 14-4-17.
//  Copyright (c) 2014年 xindao. All rights reserved.
//

#import "PetQuiltViewCell.h"
#import "XDHeader.h"
@implementation PetQuiltViewCell

-(void)dealloc
{
    self.picIV = nil;
    self.titleLB = nil;
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}
- (UIImageView *)picIV
{
    if (!_picIV) {
        _picIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 200)];
        [self addSubview:_picIV];
    }
    return _picIV;
}
- (UIImageView *)middleIV
{
    if (!_middleIV) {
        _middleIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, height_y(self.picIV)+5, 150, 30)];
        //_middleIV.image = [UIImage imageNamed:@"posts_05.png"];
        //_middleIV.backgroundColor = [UIColor clearColor];
        [self addSubview:_middleIV];
    }
    return _middleIV;
}
- (UIImageView *)bottomIV
{
    if (!_bottomIV) {
        _bottomIV = [[UIImageView alloc] init];
        //_bottomIV.backgroundColor = [UIColor clearColor];
        _bottomIV.image = [UIImage imageNamed:@"home_04.png"];
        [self addSubview:_bottomIV];
    }
    return _bottomIV;
}
- (UIImageView *)headIV
{
    if (!_headIV) {
        _headIV = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 25, 20)];
        _headIV.backgroundColor = [UIColor redColor];
        [self.middleIV addSubview:_headIV];
    }
    return _headIV;
}
- (UIImageView *)lookIV
{
    if (!_lookIV) {
        _lookIV = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 23, 13.5)];
        _lookIV.image = [UIImage imageNamed:@"posts_07.png"];
        //_lookIV.backgroundColor = [UIColor blueColor];
        [self.bottomIV addSubview:_lookIV];
    }
    return _lookIV;
}
- (UIImageView *)collectionIV
{
    if (!_collectionIV) {
        _collectionIV = [[UIImageView alloc] initWithFrame:CGRectMake(57, 2, 17.5, 17)];
        _collectionIV.image = [UIImage imageNamed:@"posts_08.png"];
        //_collectionIV.backgroundColor = [UIColor blackColor];
        [self.bottomIV addSubview:_collectionIV];
    }
    return _collectionIV;
}
- (UIImageView *)replyIV
{
    if (!_replyIV) {
        _replyIV = [[UIImageView alloc] initWithFrame:CGRectMake(107, 2, 18, 17)];
        _replyIV.image = [UIImage imageNamed:@"posts_09.png"];
        //_replyIV.backgroundColor = [UIColor orangeColor];
        [self.bottomIV addSubview:_replyIV];
    }
    return _replyIV;
}

- (UILabel *)nameLB
{
    if (!_nameLB) {
        _nameLB = [[UILabel alloc] initWithFrame:CGRectMake(2, 25, 25, 15)];
        _nameLB.backgroundColor = [UIColor clearColor];
        _nameLB.textColor = [UIColor blackColor];
        _nameLB.textAlignment = NSTextAlignmentCenter;
        _nameLB.font = [UIFont systemFontOfSize:8];
        [self.middleIV addSubview:_nameLB];
    }
    return _nameLB;
}

- (UILabel *)titleLB
{
    if (!_titleLB) {
        _titleLB = [[UILabel alloc] initWithFrame:CGRectMake(29, -2, 120, 30)];
        _titleLB.backgroundColor = [UIColor clearColor];
        _titleLB.numberOfLines = 0;
        _titleLB.font = [UIFont systemFontOfSize:10];
        [self.middleIV addSubview:_titleLB];
    }
    return _titleLB;
}
- (UILabel *)groupLB
{
    if (!_groupLB) {
        _groupLB = [[UILabel alloc] initWithFrame:CGRectMake(110, 25, 30, 15)];
        _groupLB.backgroundColor = [UIColor clearColor];
        _groupLB.textColor = [UIColor lightGrayColor];
        _groupLB.font = [UIFont systemFontOfSize:8];
        [self.middleIV addSubview:_groupLB];
    }
    return _groupLB;
}
- (UILabel *)timeLB
{
    if (!_timeLB) {
        _timeLB = [[UILabel alloc] initWithFrame:CGRectMake(60, 25, 45, 15)];
        _timeLB.backgroundColor = [UIColor clearColor];
        _timeLB.textColor = [UIColor lightGrayColor];
        _timeLB.textAlignment = NSTextAlignmentRight;
        _timeLB.font = [UIFont systemFontOfSize:8];
        [self.middleIV addSubview:_timeLB];
    }
    return _timeLB;
}
- (UILabel *)lookLB
{
    if (!_lookLB) {
        _lookLB = [[UILabel alloc] initWithFrame:CGRectMake(27, 2, 26, 16)];
        _lookLB.backgroundColor = [UIColor clearColor];
        _lookLB.textColor = [UIColor grayColor];
        _lookLB.textAlignment = NSTextAlignmentCenter;
        _lookLB.font = [UIFont systemFontOfSize:10];
        [self.bottomIV addSubview:_lookLB];
    }
    return _lookLB;
}
- (UILabel *)collectionLB
{
    if (!_collectionLB) {
        _collectionLB = [[UILabel alloc] initWithFrame:CGRectMake(77, 2, 26, 16)];
        _collectionLB.backgroundColor = [UIColor clearColor];
        _collectionLB.textColor = [UIColor redColor];
        _collectionLB.textAlignment = NSTextAlignmentCenter;
        _collectionLB.font = [UIFont systemFontOfSize:10];
        [self.bottomIV addSubview:_collectionLB];
    }
    return _collectionLB;
}
- (UILabel *)replyLB
{
    if (!_replyLB) {
        _replyLB = [[UILabel alloc] initWithFrame:CGRectMake(126, 2, 26, 16)];
        _replyLB.backgroundColor = [UIColor clearColor];
        _replyLB.textColor = [UIColor grayColor];
        _replyLB.textAlignment = NSTextAlignmentCenter;
        _replyLB.font = [UIFont systemFontOfSize:10];
        [self.bottomIV addSubview:_replyLB];
    }
    return _replyLB;
}

- (UIImage *)imageAtIndexPath:(NSIndexPath *)indexPath andItem:(NSDictionary *)dic;
{
    return  [UIImage imageNamed:[dic objectForKey:@"image"]];
}
- (void)cellForIndexPath:(NSIndexPath *)indexPath andItem:(NSDictionary *)dic height:(CGFloat)height{

   float imageHeight =  [self imageAtIndexPath:indexPath andItem:dic].size.height / 2;
    self.picIV.frame = CGRectMake(0, 0, 150, indexPath.row == 3 ? 0: imageHeight);
    self.picIV.image = [self imageAtIndexPath:indexPath andItem:dic];
    self.middleIV.frame = CGRectMake(0, height_y(self.picIV)+2, 150, 40);
    self.bottomIV.frame = CGRectMake(0, height_y(self.middleIV)+2, 150, 20);
    self.headIV.backgroundColor = [UIColor redColor];
    self.nameLB.text = @"东方小";
    self.titleLB.text = dic[@"title"];
    self.groupLB.text = @"泰迪圈";
    self.timeLB.text = @"10分钟前";
    self.lookIV.image = [UIImage imageNamed:@"posts_07.png"];;
    self.collectionIV.image = [UIImage imageNamed:@"posts_08.png"];;
    self.replyIV.image = [UIImage imageNamed:@"posts_09.png"];;
    self.lookLB.text = @"1439";
    self.collectionLB.text = @"199";
    self.replyLB.text = @"532";
   }
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
